package com.scvtc.controller.research;

import com.scvtc.domain.ResResult;
import com.scvtc.domain.dto.research.work.ResearchWorkDto;
import com.scvtc.domain.vo.PageVo;
import com.scvtc.domain.vo.research.work.ResearchWorkVo;
import com.scvtc.service.research.ResearchWorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 科研著作信息(ResearchWork)表控制层
 *
 * @author yiFei
 * @since 2022-06-02 16:17:09
 */
@Api(tags = "科研著作信息(ResearchWork)")
@RestController
@RequestMapping("researchWork")
public class ResearchWorkController {
    /**
     * 科研著作信息(ResearchWork)对象
     */
    @Autowired
    private ResearchWorkService researchWorkService;

    @GetMapping("/list")
    @ApiOperation("查询科研著作信息")
    public ResResult<PageVo<List<ResearchWorkVo>>> getAllResearchWork(
            @RequestParam(defaultValue = "1") Long current,
            @RequestParam(defaultValue = "10") Long size,
            ResearchWorkVo researchWorkVo) {
        return researchWorkService.getAllResearchWork(current, size, researchWorkVo);
    }

    @PostMapping("/")
    @ApiOperation("添加单个科研著作")
    public ResResult<?> addResearchWork(@RequestBody ResearchWorkDto researchWorkDto) {
        return researchWorkService.addResearchWork(researchWorkDto);
    }

    @PutMapping("/")
    @ApiOperation("修改单个科研著作")
    public ResResult<?> updateStudent(@RequestBody ResearchWorkDto researchWorkDto) {
        return researchWorkService.updateResearchWork(researchWorkDto);
    }

    @DeleteMapping("/")
    @ApiOperation("删除一条科研著作信息")
    public ResResult<?> deleteResearchWork(Long id) {
        return researchWorkService.deleteResearchWork(id);
    }

    @DeleteMapping("/multiple")
    @ApiOperation("删除多条科研著作信息")
    public ResResult<?> deleteMultipleResearchWork(Long[] ids) {
        return researchWorkService.deleteMultipleResearchWork(ids);
    }
}

